/**
 * https://leetcode.cn/problems/set-mismatch/
 */
function findErrorNums(nums: number[]): number[] {
  const ans: number[] = [];

  const map = new Map<number, number>()

  for (let num of nums) {
    map.set(num, (map.get(num) || 0) + 1)
  }

  for (let i = 0; i < nums.length; i++) {
      const current = map.get(i + 1)
      if (current === 2) {
          ans[1] = current
      }

      if (current === undefined) {
          ans[0] = i + 1 
      }
  }

  return ans;
}
